import { createSSRApp } from "vue";
import App from "./App.vue";
// 修正拼写错误 ↓
import globalComponents from '@/components/index'
import uviewPlus from 'uview-plus'
// import 'uno.css'

export function createApp() {
  const app = createSSRApp(App);

  // 安全遍历（防止 globalComponents 为 undefined）
  if (globalComponents) {
    Object.entries(globalComponents).forEach(([name, component]) => {
      app.component(name, component);
    });
  }

  app.use(uviewPlus, () => {
    return {
      options: {
        // 修改$u.config对象的属性
        config: {
          // 修改默认单位为rpx，相当于执行 uni.$u.config.unit = 'rpx'
          unit: 'rpx'
        }
      }
    }
  })
  return { app };
}